const actions = {
    //判断购物车是否有此商品
    addProductToCart ({ state, commit }, product) {
        return new Promise(resolve => {
            const findShopGood = state.shopCarGoods.find(element => element.iid === product.iid);
            if (findShopGood) {
                commit('incrementItemQuantity', product);
                resolve('购物车该商品数量+1')
            } else {
                commit('pushShopCarGood', product);
                resolve('添加购物车成功')
            }
        })
    },

    //判断购物车是否全选
    checkGoodsIsChose({state, commit}) {
        const isChoseAll = state.shopCarGoods.filter(element => element.isChecked).length === state.shopCarGoods.length;
        commit('changeIsChooseAll', isChoseAll)
    },
}

export default actions;